Conversation
46b87bc to
a50bc0d
Compare
|
I've looked around a bit and could not find any big ruby project which specifies the bundler version in the Gemfile but also don't see any harm in it. For air-gapped envs this could be beneficial to detect version mismatches earlier. From my point this can be merged. |
a50bc0d to
2014891
Compare
|
FYI: I've created an action [1] that sets the [1] https://github.com/cloudfoundry/cloud_controller_ng/actions/workflows/bump_bundler_version.yml |
Co-authored-by: Johannes Haass <johannes.haass@sap.com>
This reverts commit 728f705.
385ba16 to
c8325f2
Compare
|
That seems like a good plan until we ever decide to desync bundler and the Ruby version (which we might want to do to upgrade to 3.3). I updated this PR to account for the bump to Ruby 3.2.9. Should I remove the inclusion of bundler in the Gemfile? |
These are logs from an air-gapped compilation VM when the bundler lock a non-default Bundler version. This causes the compilation step to take a long time, but it does eventually succeed. I seem to recall hitting errors when desyncing the bundler version, but I cannot reproduce them now. There was an old issue that also had to do with an issue in the ruby bosh package itself, but I don't think it was the mismatched bundler version alone. Still, it doesn't seem great that the compilation phase wastes time trying to connect to RubyGems, and I'm not sure what kind of issues might arise from using the wrong bundler version. Vendoring bundler is not actually possible, even if specified in the Gemfile. Bundler seems to make an exception for itself and it will not appear in vendor/cache. So this solution will not work (and would be more complicated anyway, as the bundled gem wouldn't immediately become available to the system gem space)--we would instead to do something like this: (alternatively, just commit the gemfile directly to our repo) Given this isn't an outright failure, I'm not sure it's worth the trouble. On the other hand, I still wouldn't be comfortable desyncing the bundler version since offline envs would end up having subtle differences, and I'm not sure there is another way to prevent |
The Problem
There's some tricky behaviour with the CAPI pre-packaging/packaging process and how it uses Bundler that I think can be particularly confusing, especially to those new to contributing to CCNG that'd I'd like to document here and hopefully mitigate with this PR.
Cloud Controller must always use the default Bundler version with its Ruby version, or CAPI releases will not work on air-gapped environments.
This happens if a the
BUNDLED WITHversion in the Gemfile.lock is bumped beyond the default, meaning that when it comes time to runbundlein the packaging step, bundler will notice that it does not have the correct version, attempt to download the right version, and fail.I think these issues can be mitigated by adding the Bundler and Ruby versions to our Gemfile.
Adding bundler to our Gemfile:
If you try to create a dev release with a different version (say you accidentally chruby'd 3.3 so now Bundler is 2.5.X), you get an error during prepackaging:
It also won't be possible to bump Gemfile.lock to a new
BUNDLED WITHversion during abundle update.Adding bundler to our Gemfile may allow us to use newer versions of Bundler than what's the Ruby version's default because now the Bundler gem will be vendored like the others and the compilation VM won't need to download it. But I'd have to test on an air-gapped env just to be sure.
That said, I did find this solution relatively inconsistent--there were times where I thought creating a new release would error out because of the Bundler version I had selected, and it was somehow able to succeed.
Adding Ruby version to our Gemfile
Because of the prepackaging step, creating a CAPI bosh release (in this context, usually for testing) is reliant on having the correct Ruby version selected. This might manifest in errors during runtime or compilation, but I've seen this fail most frequently because the wrong Bundler version would be inadvertently selected, and gems would be vendored/packaged with Bundler 2.5, which would hit this bug with Bundler 2.5.
That makes this a little redundant with adding the Bundler version to the Gemfile, but adding the Ruby version to the Gemfile will instead will fail quickly during prepackaging with a clear message:
It will also raise an error if someone tries to run CCNG tests (or
bundle install, etc) with the wrong Ruby version.I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
mainbranchI have run all the unit tests using
bundle exec rakeI have run CF Acceptance Tests